<template>
	<view class="videListBox">
		<view class="videoItem" v-for="(item,index) in videoList" :key="index" @click="itemEvent(item.type,item.vid,index)">
			<view class="imgBox">
				<image :src="item.coverUrl" mode="aspectFill" style="height: 410rpx;margin-left: -50rpx;"></image>
				<view class="playCount">
					<image src="/static/images/play-g.png" mode="widthFix"></image>
					<text>{{$tools.calcPlayCount(item.playTime)}}</text>
				</view>
				<view class="time">
					<text>{{$tools.StoM(item.durationms / 1000)}}</text>
				</view>
			</view>
			<view class="videoName">
				<text>{{item.title}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapMutations
	} from 'vuex'
	import {
		getVideoUrl,
		getVideoDetail
	} from '@/api/video.js'
	import {
		search
	} from '@/api/search.js'
	export default {
		props: {
			videoList: {
				type: Array,
				default: []
			},
			videoType: {
				type: String,
				default: 'video'
			}
		},
		data() {
			return {}
		},
		onLoad() {

		},
		methods: {
			...mapMutations(['changeVideoList', 'changeMusicPlayStatus']),
			itemEvent(type, vid, index) {
				const that = this
				if (type == 1) {
					uni.navigateTo({
						url: `/pages/video/video/videoDetail?id=${vid}`
					})
				} else {
					uni.navigateTo({
						url: `/pages/video/MV/mvDetail?id=${vid}`
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.videListBox {
		width: 750rpx;
		padding: 0 30rpx;

		.videoItem {
			width: 330rpx;
			height: 530rpx;
			display: inline-block;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			overflow: hidden;
			box-shadow: 2rpx 2rpx 8rpx 4rpx rgba(0, 0, 0, .12);

			&:nth-child(even) {
				margin-left: 15rpx;
			}

			&:nth-child(odd) {
				margin-right: 15rpx;
			}

			.imgBox {
				position: relative;
				width: 330rpx;
				height: 410rpx;

				.playCount {
					display: flex;
					align-items: center;
					position: absolute;
					width: 120rpx;
					height: 40rpx;
					bottom: 10rpx;
					left: 10rpx;
					color: #ccc;
					font-size: 26rpx;
					z-index: 11;

					image {
						width: 25rpx;
					}
				}

				.time {
					position: absolute;
					width: 120rpx;
					height: 40rpx;
					bottom: 10rpx;
					right: -40rpx;
					color: #ccc;
					font-size: 26rpx;
					z-index: 11;
				}
			}

			.videoName {
				width: 330rpx;
				height: 100rpx;
				padding: 20rpx;
				font-size: 28rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				-webkit-box-orient: vertical;
			}
		}
	}
</style>
